package com.kaili.db.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.kaili.client.service.ILoginUserInfoService;
import com.kaili.pojo.dto.notice.NoticeAddDTO;
import com.kaili.pojo.entity.HsOptEwb;
import com.kaili.pojo.entity.HsOptEwbNotice;
import com.kaili.db.mapper.HsOptEwbNoticeMapper;
import com.kaili.db.service.IHsOptEwbNoticeService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.kaili.pojo.vo.EwbNoticeVO;
import com.kaili.common.exception.BaseExcept;
import com.kaili.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cgm
 * @since 2018-05-08
 */
@Service
@Transactional
public class HsOptEwbNoticeServiceImpl extends ServiceImpl<HsOptEwbNoticeMapper, HsOptEwbNotice> implements IHsOptEwbNoticeService {

    @Autowired
    private ILoginUserInfoService login;


    /**
     * 派送-自提转换
     * @param hsOptEwbNotice
     * @return
     * @throws BaseExcept
     */
    @Override
    public int createdEwbNotice(NoticeAddDTO hsOptEwbNotice) throws BaseExcept {
        hsOptEwbNotice.setCreatedTime(DateUtils.getNowDate());
        HsOptEwb ewb = new HsOptEwb();
        ewb.setEwbNo(hsOptEwbNotice.getEwbNo());
        ewb.setSendCharge(hsOptEwbNotice.getDeliveryChargeNew());
        ewb.setPickGoodsModeId(hsOptEwbNotice.getAdjustStatus());
        baseMapper.modifiedEwb(ewb);
        baseMapper.createdEwbNotice(hsOptEwbNotice);

        return 0;

    }

    @Override
    public void modifiedNotice(String ewbNo) throws BaseExcept {
        baseMapper.modifiedNotice(ewbNo);
    }

    @Override
    public Page<EwbNoticeVO> queryEwbNoticeList(Page<EwbNoticeVO> page, Map search) throws BaseExcept {
        return page.setRecords(baseMapper.queryEwbAppointList(page,search));
    }
}
